﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Samurai.Infrastructure;
using System.ComponentModel;
using System.Windows.Input;
using Samurai.Client.Commands;

namespace Samurai.Client.DataContexts
{
    public class EditMovieDataContext : ADataContext
    {
        public CommandBase PreviewMovieCommand { get; set; }
        public ICommand CommitMovieEditCommand { get; set; }
        public ICommand CancelMovieEditCommand { get; set; }

        private bool _isClosed;
        public bool IsClosed
        {
            get { return _isClosed; }
            set
            {
                _isClosed = value;
                OnPropertyChanged("IsClosed");
            }
        }

        private string _title;
        public string Title
        {
            get
            {
                return _title;
            }
            set
            {
                _title = value;
                OnPropertyChanged("Title");
            }
        }

        private string _path;
        public string Path
        {
            get
            {
                return _path;
            }
            set
            {
                _path = value;
                OnPropertyChanged("Path");
            }
        }

        private byte[] _image;
        public byte[] Image
        {
            get
            {
                return _image;
            }
            set
            {
                _image = value;
                OnPropertyChanged("Image");
            }
        }

        private Movie _movie;
        public Movie Movie {

            get { return _movie; }
            set
            {
                _movie = value;
                OnPropertyChanged("Movie");
            }
        }

        public EditMovieDataContext(Movie movie)
        {
            Movie = movie;
            Title = movie.Title;
            Image = movie.Image;
            Path = movie.Path;

            PreviewMovieCommand = new PreviewMovieCommand(this);            
            CommitMovieEditCommand = new CommitMovieEditCommand(this);
            CancelMovieEditCommand = new CancelMovieEditCommand(this);

            TakeLongOperationAction(PreviewMovieCommand);
        }        

        public override void OnLoaded()
        {
            
        }
    }
}
